import VuiElement from '../../base/element';
import VuiContainer from '../container';
import VuiText from '../text';
import './style.css';

/**
 * 下拉菜单中带标题的面板
 */
export default class VuiDropdownPanel extends VuiElement {
  constructor(title) {
    super();
    this._className = {
      container: 'vui-dropdown-panel-container',
      title: 'vui-dropdown-panel-title',
      content: 'vui-dropdown-panel-content vui-clearfix'
    };
    this.config = { title };
  }

  initUI() {
    const cls = this._className;
    const config = this.config;
    this.container = this.createDiv(cls.container);
    if (config.title) {
      const title = VuiText.newInstance(config.title, cls.title);
      this.append(title);
    }
    const content = VuiContainer.newInstance(cls.content);
    this.content = content;
    this.append(content);
  }

  addItems(items) {
    this.content.append(items);
  }
}
